<div class="page-header">
	<h2>Phí vận chuyển</h2>
</div>
<!--
<div class="btn-group" style="float:right;">
	<a class="btn" href="<?php echo site_url($this->config->item('admin_folder').'/shipping/ship_location'); ?>"><i class="icon-plus-sign"></i> Thêm mã vùng</a>
</div>
-->

<table class="table table-striped" cellspacing="0" cellpadding="0">
	<thead>
		<tr>
			<th> Trọng lượng \ Vùng </th>
			<?php foreach($ship_locations as $item){?>
            <th align="center"><?php echo $item->value;?></th>
            <?php }?>
            <th></th>
		</tr>
	</thead>

	<tbody>
<?php 
if(@$weight_id!=''){?>

<?php foreach ($ship_weights as $item): if($weight_id == $item->id || $weight_id == 0 ){ if($weight_id == 0 ) $item->id = 0;?>
		<tr>
        	<form action="<?php echo  site_url($this->config->item('admin_folder').'/shipping/edit_ship_cost/'.$item->id); ?>" method="post">
			<td align="right"><?php if($item->id==0) echo 'Thêm mõi 500';else echo $item->value;?> (g)</td>            
            <?php foreach ($ship_costs as $cost):?>
            	<?php if($cost->weight_id==$item->id){?>
                	<td><input value="<?php echo $cost->value?>" name="ship_cost[]" style=" width:65px"/> đ
                    	<input type="hidden" name="location_id[]" value="<?php echo $cost->location_id?>" />
                    </td>
                <?php }?>
            <?php endforeach; ?>
			<td>
				<div class="btn-group" style="float:right;">
                	<input class="btn" type="submit" value="Save" />
                    <a class="btn" href="<?php echo  site_url($this->config->item('admin_folder').'/shipping/ship_cost'); ?>"> Cancel </a>
				</div>
			</td>
            </form>
	  </tr>
<?php break;} endforeach; ?>

<?php }else{?>
<?php foreach ($ship_weights as $item):?>
		<tr>
			<td align="right"><?php if($item->id == 0) echo 'Thêm mõi ';echo $item->value;?> (g)</td>
            <?php foreach ($ship_costs as $cost):?>
            	<?php if($cost->weight_id==$item->id){?>
                	<td><?php echo format_currency($cost->value);?></td>
                <?php }?>
            <?php endforeach; ?>
			<td>
				<div class="btn-group" style="float:right;">
					<a class="btn" href="<?php echo  site_url($this->config->item('admin_folder').'/shipping/edit_ship_cost/'.$item->id); ?>"><i class="icon-pencil"></i> <?php echo lang('edit');?></a>
				</div>
			</td>
	  </tr>
<?php endforeach; ?>

	<!--
	  <tr>
			<td align="right">Thêm mõi 500(g)</td>
            <?php foreach ($ship_costs as $cost):?>
            	<?php if($cost->weight_id==0){?>
                	<td><?php echo format_currency($cost->value);?></td>
                <?php }?>
            <?php endforeach; ?>
			
			<td>
				<div class="btn-group" style="float:right;">
					<a class="btn" href="<?php echo  site_url($this->config->item('admin_folder').'/shipping/edit_ship_cost/0'); ?>"><i class="icon-pencil"></i> <?php echo lang('edit');?></a>
				</div>
			</td>
	  </tr>
    -->  
	</tbody>
<?php }?>
</table>